<?php
namespace app\app\controller\v1;
use app\app\Appbase;
use app\admin\model\SystemParamValue;
//
//套餐
//
class UserMeal extends Appbase 
{
	
	/**
	*已购套餐
	* /app/v1/user_meal/ygMeal
	* 需要登录 
	* @is_need_login true
	* @method all
	*/
	public function ygMeal($staff_id='')
    {
		try {
			$shopId = -1;
			if($staff_id){
				$shopId =  model('ShopStaff')->where('id',$staff_id)->value('shop_id');
			}
			$data = model("UserYgMeal")->getYgMeal(request()->userId,$shopId);
			return $this->ReSucess($data);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
    }
	
	/**
	*在售套餐
	* /app/v1/user_meal/zsMeal
	* 需要登录 
	* @is_need_login true
	* @method all
	*/
	public function zsMeal()
    {
		try {
	        $model =  model("goods")->getModel();
	        $model =  $model ->where('a.type',1);
	        $goods =  $model ->all();
	        foreach($goods as $key=>$value ){
	        	$value['total_num'] =  $value ->GoodsMeal()->sum('num');
	        }
	        return $this->ReSucess($goods);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
    }
    
    
    /**
	*在售套餐
	* /app/v1/user_meal/ygGetails
	* 需要登录 
	* @is_need_login true
	* @method all
	*/
	public function ygGetails($id)
    {
    	try {
			$data = model("UserYgMeal")->details($id);
			return $this->ReSucess($data);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
    }
    
}



